package com.jwater.core.manager.master;

import java.util.List;

import com.jwater.core.manager.common.model.*;

/**
 * @description: master上下文
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public class MasterContextImpl implements MasterContext {
    private MasterNode masterNode;

    @Override
    public MasterNode getMasterNode() {
        return masterNode;
    }

    protected void setMasterNode(MasterNode masterNode) {
        this.masterNode = masterNode;
    }

    @Override
    public WorkerInfo getWorkerInfo(String regionName, String deployName, String groupName, String workerName) {
        return masterNode.getWorkerInfo(regionName, deployName, groupName, workerName);
    }

    @Override
    public List<WorkerInfo> getWorkerList(String regionName) {
        return masterNode.getWorkerList(regionName);
    }

    @Override
    public List<String> getWorkerConfList(String regionName, String deployName) {
        return masterNode.getWorkerConfList(regionName, deployName);
    }

    @Override
    public List<String> getWorkerConfRoot(String regionName, String deployName) {
        return masterNode.getWorkerConfRoot(regionName, deployName);
    }

    @Override
    public void startWorker(String regionName, String deployName, String groupName, String workerName, int index) {
        masterNode.startWorker(regionName, deployName, groupName, workerName, index);
    }

    @Override
    public void stopWorker(String regionName, String deployName, String groupName, String workerName, int index,
                           boolean isForce) {
        masterNode.stopWorker(regionName, deployName, groupName, workerName, index, isForce);
    }

    @Override
    public List<JobInfo> getJobList(String regionName) {
        return masterNode.getJobList(regionName);
    }

    @Override
    public void startJob(String regionName, String deployName, String groupName, String jobName) {
        masterNode.startJob(regionName, deployName, groupName, jobName);
    }

    @Override
    public void stopJob(String regionName, String deployName, String groupName, String jobName) {
        masterNode.stopJob(regionName, deployName, groupName, jobName);
    }

    @Override
    public void runJob(String regionName, String deployName, String groupName, String jobName, long time,
                       boolean once) {
        masterNode.runJob(regionName, deployName, groupName, jobName, time, once);
    }

    @Override
    public void killJob(String regionName, String deployName, String groupName, String jobName) {
        masterNode.killJob(regionName, deployName, groupName, jobName);
    }

    @Override
    public void loadConf(String regionName) {
        masterNode.loadConf(regionName);
    }

    @Override
    public List<SystemInfo> getAllSystemInfo() {
        return masterNode.getAllSystemInfo();
    }

    @Override
    public void removeAlarmInfo(String type) {
        masterNode.removeAlarmInfo(type);
    }

    @Override
    public List<AlarmInfo> getAllAlarmInfo() {
        return masterNode.getAllAlarmInfo();
    }

    @Override
    public List<PackageInfo> getPackageInfo() {
        return masterNode.getPackageInfo();
    }

    @Override
    public List<GatewayProxyInfo> getGatewayProxyInfo(String gatewayGroupName, String gatewayWorkerName) {
        return masterNode.getGatewayProxyInfo(gatewayGroupName, gatewayWorkerName);
    }

    @Override
    public List<GatewayProxyInfo> getGatewayProxyInfo(String gatewayGroupName, String gatewayWorkerName, int gatewayIndex,
                                                      String gatewayRegionName, String gatewayDeployName) {
        return masterNode.getGatewayProxyInfo(gatewayGroupName, gatewayWorkerName, gatewayIndex, gatewayRegionName, gatewayDeployName);
    }

}
